package com.hnkywl.sts.action.kcgl;

import com.google.gson.Gson;
import com.hnkywl.sts.dao.kcgl.KcgdDao;
import com.hnkywl.sts.entity.sys.Gncz;
import com.hnkywl.sts.service.kcgl.KcgdService;
import com.hnkywl.sts.service.sys.GnczService;
import com.hnkywl.sts.service.xsgl.XsdService;
import com.hnkywl.sts.util.POIUtil;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.Region;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: lenovo
 * Date: 13-4-30
 * Time: 上午11:34
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/kcgl/kcgd")
public class KcgdAction extends SimpleActionSupport {
    private KcgdService kcgdService;
    private XsdService xsdService;
    private KcgdDao kcgdDao;
    //分页组件 起始位置
    private int page;
    //分页组件 页面大小
    private int rows;
    //行索引
    private int index;
    //功能操作
    private List<Gncz> gnczList;
    private GnczService gnczService;
    // 查询条件
    private String gdwyh;
    private String clh;
    private String bh;
    private String cpm;
    private String pm;
    private String cz;
    private String ggxh;
    private String zyzt;
    private String kcgdstart;
    private String kcgdend;

    @Action("kcgd")
    public String kcgd() {
        gnczList = gnczService.findGnczByJsAndUrl(request.getServletPath());
        return SUCCESS;
    }

    // 实时库存列表
    @Action("kcgdList")
    public void kcgdList() {
        this.renderJson(this.kcgdService.findList(gdwyh, clh, bh, cpm, pm, cz, ggxh, zyzt, kcgdstart, kcgdend, page, rows));
    }

    //挂单实际方法
    @Action("kcgd_gd")
    public void kcgdGd() {
        try {
            String res = kcgdService.gd(null);
            renderText("{\"statusCode\":\"200\", \"message\":\"" + res + "\", \"operationType\":\"add\"}");
        } catch (Exception e) {
            e.printStackTrace();
            renderText("{\"statusCode\":\"300\", \"message\":\"" + e.getMessage() + "\"}");
        }
    }

    /**
     * 实时库存的导出
     *
     * @return
     */
    @Action("kcgd_export")
    public String kcgdExport() {
        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
        List<Map> kcgdList = this.kcgdDao.findKhList(null, null, null, null, null, null, null, null, null);
        //第一步，创建一个webbook，对应一个Excel文件
        HSSFWorkbook wb = new HSSFWorkbook();
        //第二步，在webbook中添加一个sheet,对应Excel文件中的sheet
        HSSFSheet sheet = wb.createSheet("实时库存");
        POIUtil poiUtil = new POIUtil(wb);
        //设置列宽
        sheet.setDefaultRowHeightInPoints(15);
        sheet.setDefaultColumnWidth((short) 17);
        sheet.setColumnWidth((short) 0, (short) (11 * 512));
        sheet.setColumnWidth((short) 1, (short) (9 * 512));
        sheet.setColumnWidth((short) 2, (short) (9 * 512));
        sheet.setColumnWidth((short) 3, (short) (15 * 512));
        sheet.setColumnWidth((short) 4, (short) (15 * 512));
        sheet.setColumnWidth((short) 5, (short) (6 * 512));
        sheet.setColumnWidth((short) 6, (short) (6 * 512));
        sheet.setColumnWidth((short) 7, (short) (10 * 512));
        sheet.setColumnWidth((short) 8, (short) (6 * 512));
        sheet.setColumnWidth((short) 9, (short) (6 * 512));
        sheet.setColumnWidth((short) 10, (short) (6 * 512));
        sheet.setColumnWidth((short) 11, (short) (10 * 512));
        sheet.setColumnWidth((short) 12, (short) (10 * 512));
        sheet.setColumnWidth((short) 13, (short) (10 * 512));
        sheet.setColumnWidth((short) 14, (short) (12 * 512));
        sheet.setColumnWidth((short) 15, (short) (12 * 512));
        sheet.setColumnWidth((short) 16, (short) (14 * 512));
        sheet.setColumnWidth((short) 17, (short) (12 * 512));
        //第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
        HSSFRow row = sheet.createRow((int) 0);
        row.setHeightInPoints(36);
        //第四步，创建单元格，并设置值表头  设置表头居中
        HSSFCellStyle titleStyle = poiUtil.createTitleHSSFCellStyle(wb);
        HSSFCell titleCell = row.createCell((short) 0);
        titleCell.setCellStyle(titleStyle);
        titleCell.setEncoding(HSSFCell.ENCODING_UTF_16);
        titleCell.setCellValue("实时库存导出汇总表");
        // 四个参数分别是：起始行，起始列，结束行，结束列
        sheet.addMergedRegion(new Region(0, (short) 0, 0, (short) 16));
        row = sheet.createRow((int) 1);
        row.setHeightInPoints(21);
        //生成第一行数据
        HSSFCell kcbm = row.createCell((short) 0);
        kcbm.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        kcbm.setEncoding(HSSFCell.ENCODING_UTF_16);
        kcbm.setCellValue("卡号");

        HSSFCell oldwzbm = row.createCell((short) 1);
        oldwzbm.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        oldwzbm.setEncoding(HSSFCell.ENCODING_UTF_16);
        oldwzbm.setCellValue("老物资编码");

        HSSFCell wzbm = row.createCell((short) 2);
        wzbm.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        wzbm.setEncoding(HSSFCell.ENCODING_UTF_16);
        wzbm.setCellValue("新物资编码");

        HSSFCell wzname = row.createCell((short) 3);
        wzname.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        wzname.setEncoding(HSSFCell.ENCODING_UTF_16);
        wzname.setCellValue("物资名称");

        HSSFCell wzgg = row.createCell((short) 4);
        wzgg.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        wzgg.setEncoding(HSSFCell.ENCODING_UTF_16);
        wzgg.setCellValue("规格型号");

        HSSFCell cd = row.createCell((short) 5);
        cd.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        cd.setEncoding(HSSFCell.ENCODING_UTF_16);
        cd.setCellValue("产地");

        HSSFCell dw = row.createCell((short) 6);
        dw.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        dw.setEncoding(HSSFCell.ENCODING_UTF_16);
        dw.setCellValue("单位");

        HSSFCell sl = row.createCell((short) 7);
        sl.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        sl.setEncoding(HSSFCell.ENCODING_UTF_16);
        sl.setCellValue("数量");

        HSSFCell chd = row.createCell((short) 8);
        chd.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        chd.setEncoding(HSSFCell.ENCODING_UTF_16);
        chd.setCellValue("长度");

        HSSFCell js = row.createCell((short) 9);
        js.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        js.setEncoding(HSSFCell.ENCODING_UTF_16);
        js.setCellValue("件数");

        HSSFCell jz = row.createCell((short) 10);
        jz.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        jz.setEncoding(HSSFCell.ENCODING_UTF_16);
        jz.setCellValue("件重");

        HSSFCell kkdsl = row.createCell((short) 11);
        kkdsl.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        kkdsl.setEncoding(HSSFCell.ENCODING_UTF_16);
        kkdsl.setCellValue("可开单数量");

        HSSFCell wsdj = row.createCell((short) 12);
        wsdj.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        wsdj.setEncoding(HSSFCell.ENCODING_UTF_16);
        wsdj.setCellValue("无税单价(元)");

        HSSFCell wsje = row.createCell((short) 13);
        wsje.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        wsje.setEncoding(HSSFCell.ENCODING_UTF_16);
        wsje.setCellValue("无税总金额(元)");

        HSSFCell kcgdcgdh = row.createCell((short) 14);
        kcgdcgdh.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        kcgdcgdh.setEncoding(HSSFCell.ENCODING_UTF_16);
        kcgdcgdh.setCellValue("采购单号");

        HSSFCell ck = row.createCell((short) 15);
        ck.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        ck.setEncoding(HSSFCell.ENCODING_UTF_16);
        ck.setCellValue("仓库");

        HSSFCell rkrq = row.createCell((short) 16);
        rkrq.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        rkrq.setEncoding(HSSFCell.ENCODING_UTF_16);
        rkrq.setCellValue("入库日期");

        HSSFCell cggs = row.createCell((short) 17);
        cggs.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        cggs.setEncoding(HSSFCell.ENCODING_UTF_16);
        cggs.setCellValue("采购公司");
        //表体部分
        for (int i = 2; i < kcgdList.size() + 2; i++) {
            row = sheet.createRow(i);
            row.setHeightInPoints(19);

            kcbm = row.createCell((short) 0);
            kcbm.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            kcbm.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("khbm")) {
                kcbm.setCellValue(kcgdList.get(i - 2).get("khbm").toString());
            }

            oldwzbm = row.createCell((short) 1);
            oldwzbm.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            oldwzbm.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("jtwz_oldcode")) {
                oldwzbm.setCellValue(kcgdList.get(i - 2).get("jtwz_oldcode").toString());
            }

            wzbm = row.createCell((short) 2);
            wzbm.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            wzbm.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("jtwz_code")) {
                wzbm.setCellValue(kcgdList.get(i - 2).get("jtwz_code").toString());
            }

            wzname = row.createCell((short) 3);
            wzname.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            wzname.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("jtwz_name")) {
                wzname.setCellValue(kcgdList.get(i - 2).get("jtwz_name").toString());
            }

            wzgg = row.createCell((short) 4);
            wzgg.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            wzgg.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("jtwz_ggxh")) {
                wzgg.setCellValue(kcgdList.get(i - 2).get("jtwz_ggxh").toString());
            }

            cd = row.createCell((short) 5);
            cd.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            cd.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("cd_z")) {
                cd.setCellValue(kcgdList.get(i - 2).get("cd_z").toString());
            }

            dw = row.createCell((short) 6);
            dw.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            dw.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("dw_z")) {
                dw.setCellValue(kcgdList.get(i - 2).get("dw_z").toString());
            }

            sl = row.createCell((short) 7);
            sl.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            sl.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("sl")) {
                BigDecimal bigDecimal_sl = new BigDecimal(kcgdList.get(i - 2).get("sl").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                sl.setCellValue(bigDecimal_sl.doubleValue());
            }

            chd = row.createCell((short) 8);
            chd.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            chd.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("chd")) {
                chd.setCellValue(kcgdList.get(i - 2).get("chd").toString());
            }

            js = row.createCell((short) 9);
            js.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            js.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("js")) {
                js.setCellValue(kcgdList.get(i - 2).get("js").toString());
            }

            jz = row.createCell((short) 10);
            jz.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            jz.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("jz")) {
                jz.setCellValue(kcgdList.get(i - 2).get("jz").toString());
            }

            kkdsl = row.createCell((short) 11);
            kkdsl.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            kkdsl.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("kkdsl")) {
                BigDecimal bigDecimal_kkdsl = new BigDecimal(kcgdList.get(i - 2).get("kkdsl").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                kkdsl.setCellValue(bigDecimal_kkdsl.doubleValue());
            }

            wsdj = row.createCell((short) 12);
            wsdj.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            wsdj.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("wsdj")) {
                BigDecimal bigDecimal_wsdj = new BigDecimal(kcgdList.get(i - 2).get("wsdj").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                wsdj.setCellValue(bigDecimal_wsdj.doubleValue());
            }

            wsje = row.createCell((short) 13);
            wsje.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            wsje.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("wsje")) {
                BigDecimal bigDecimal_wsje = new BigDecimal(kcgdList.get(i - 2).get("wsje").toString()).setScale(3, BigDecimal.ROUND_HALF_UP);
                wsje.setCellValue(bigDecimal_wsje.doubleValue());
            }

            kcgdcgdh = row.createCell((short) 14);
            kcgdcgdh.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            kcgdcgdh.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("cgd_cgdh")) {
                kcgdcgdh.setCellValue(kcgdList.get(i - 2).get("cgd_cgdh").toString());
            }

            ck = row.createCell((short) 15);
            ck.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            ck.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("ck_mc")) {
                ck.setCellValue(kcgdList.get(i - 2).get("ck_mc").toString());
            }

            rkrq = row.createCell((short) 16);
            rkrq.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            rkrq.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("rkrq")) {
                rkrq.setCellValue(kcgdList.get(i - 2).get("rkrq").toString());
            }

            cggs = row.createCell((short) 17);
            cggs.setCellStyle(poiUtil.createContentHSSFCellStyle(wb));
            cggs.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != kcgdList.get(i - 2).get("cggs_jc")) {
                cggs.setCellValue(kcgdList.get(i - 2).get("cggs_jc").toString());
            }
        }

        List<Map> sumList = kcgdDao.findSumKh(null, null, null, null, null, null, null, null, null, null);
        Double total_sl = 0d;
        Double total_kkdsl = 0d;
        Double total_wsje = 0d;
        if (sumList.size() != 0) {
            for (Map map : sumList) {
                total_sl += Double.valueOf((map.get("sumsl") == null ? 0d : map.get("sumsl")).toString());
                total_kkdsl += Double.valueOf((map.get("sumkkdsl") == null ? 0d : map.get("sumkkdsl")).toString());
                total_wsje += Double.valueOf((map.get("wsje") == null ? 0d : map.get("wsje")).toString());
            }
        }
        BigDecimal bigDecimal_total_sl = new BigDecimal(total_sl).setScale(3, BigDecimal.ROUND_HALF_UP);
        BigDecimal bigDecimal_total_kkdsl = new BigDecimal(total_kkdsl).setScale(3, BigDecimal.ROUND_HALF_UP);
        BigDecimal bigDecimal_total_wsje = new BigDecimal(total_wsje).setScale(3, BigDecimal.ROUND_HALF_UP);

        //合计
        row = sheet.createRow(kcgdList.size() + 2);
        row.setHeightInPoints(19);
        HSSFCell total_kcbm = row.createCell((short) 0);
        total_kcbm.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_kcbm.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_kcbm.setCellValue("合计：");

        HSSFCell total_oldwzbm = row.createCell((short) 1);
        total_oldwzbm.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_oldwzbm.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_oldwzbm.setCellValue("");

        HSSFCell total_wzbm = row.createCell((short) 2);
        total_wzbm.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_wzbm.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_wzbm.setCellValue("");

        HSSFCell total_wzname = row.createCell((short) 3);
        total_wzname.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_wzname.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_wzname.setCellValue("");

        HSSFCell total_wzgg = row.createCell((short) 4);
        total_wzgg.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_wzgg.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_wzgg.setCellValue("");

        HSSFCell total_cd = row.createCell((short) 5);
        total_cd.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_cd.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_cd.setCellValue("");

        HSSFCell total_dw = row.createCell((short) 6);
        total_dw.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_dw.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_dw.setCellValue("");

        HSSFCell total_sl_hj = row.createCell((short) 7);
        total_sl_hj.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_sl_hj.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_sl_hj.setCellValue(bigDecimal_total_sl.toString());

        HSSFCell total_chd = row.createCell((short) 8);
        total_chd.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_chd.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_chd.setCellValue("");

        HSSFCell total_js = row.createCell((short) 9);
        total_js.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_js.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_js.setCellValue("");

        HSSFCell total_jz = row.createCell((short) 10);
        total_jz.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_jz.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_jz.setCellValue("");

        HSSFCell total_kkdsl_hj = row.createCell((short) 11);
        total_kkdsl_hj.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_kkdsl_hj.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_kkdsl_hj.setCellValue(bigDecimal_total_kkdsl.doubleValue());

        HSSFCell total_wsdj = row.createCell((short) 12);
        total_wsdj.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_wsdj.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_wsdj.setCellValue("");

        HSSFCell total_wsje_hj = row.createCell((short) 13);
        total_wsje_hj.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_wsje_hj.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_wsje_hj.setCellValue(bigDecimal_total_wsje.doubleValue());

        HSSFCell total_kcgdcgdh = row.createCell((short) 14);
        total_kcgdcgdh.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_kcgdcgdh.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_kcgdcgdh.setCellValue("");

        HSSFCell total_ck = row.createCell((short) 15);
        total_ck.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_ck.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_ck.setCellValue("");

        HSSFCell total_rkrq = row.createCell((short) 16);
        total_rkrq.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_rkrq.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_rkrq.setCellValue("");

        HSSFCell total_cggs = row.createCell((short) 17);
        total_cggs.setCellStyle(poiUtil.createHeaderHSSFCellStyle(wb));
        total_cggs.setEncoding(HSSFCell.ENCODING_UTF_16);
        total_cggs.setCellValue("");

        try {
            response.setContentType("application/x-download");
            String filedisplay = new String(("实时库存汇总表.xls").getBytes("gb2312"), "iso8859-1");
            response.addHeader("Content-Disposition", "attachment;filename=" + filedisplay);
            wb.write(response.getOutputStream());
            response.getOutputStream().close();
        } catch (Exception e) {
            e.printStackTrace();
            renderText("位置异常，导出失败" + e.getMessage());
        }
        return null;
    }


    //销售单明细
    @Action("kcgd_xsmx")
    public void kcgdXsmx() {
        Gson gson = new Gson();
        //出库件数
        Integer ck_js = 0;
        //出库数量
        Double ck_sbsl = 0d;
        Double sbsl = 0d;
        String result = "";
        List<Map> xsmx = this.xsdService.findXsmxByKh(null);
        if (xsmx.size() > 0) {
            for (Map map : xsmx) {
                sbsl += map.get("sbsl") == null ? 0d : (Double) map.get("sbsl");
                ck_js += map.get("ck_js") == null ? 0 : (Integer) map.get("ck_js");
                ck_sbsl += map.get("ck_sbsl") == null ? 0d : (Double) map.get("ck_sbsl");
            }
            result = "{\"rows\":" + gson.toJson(xsmx) + ",\"footer\":[{\"xsd.xsdh\":\"销售合计:\",\"sbsl\":" + sbsl + ",\"ck_js\":" + ck_js + ",\"ck_sbsl\":" + ck_sbsl + "}]}";
        } else {
            result = "{\"rows\":" + gson.toJson(xsmx) + "}";
        }
        this.renderJson(result);
    }

    //=========getter===setter====================

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public List<Gncz> getGnczList() {
        return gnczList;
    }

    public void setGnczList(List<Gncz> gnczList) {
        this.gnczList = gnczList;
    }

    public String getGdwyh() {
        return gdwyh;
    }

    public void setGdwyh(String gdwyh) {
        this.gdwyh = gdwyh;
    }

    public String getClh() {
        return clh;
    }

    public void setClh(String clh) {
        this.clh = clh;
    }

    public String getBh() {
        return bh;
    }

    public void setBh(String bh) {
        this.bh = bh;
    }

    public String getCpm() {
        return cpm;
    }

    public void setCpm(String cpm) {
        this.cpm = cpm;
    }

    public String getPm() {
        return pm;
    }

    public void setPm(String pm) {
        this.pm = pm;
    }

    public String getCz() {
        return cz;
    }

    public void setCz(String cz) {
        this.cz = cz;
    }

    public String getGgxh() {
        return ggxh;
    }

    public void setGgxh(String ggxh) {
        this.ggxh = ggxh;
    }

    public String getZyzt() {
        return zyzt;
    }

    public void setZyzt(String zyzt) {
        this.zyzt = zyzt;
    }

    public String getKcgdstart() {
        return kcgdstart;
    }

    public void setKcgdstart(String kcgdstart) {
        this.kcgdstart = kcgdstart;
    }

    public String getKcgdend() {
        return kcgdend;
    }

    public void setKcgdend(String kcgdend) {
        this.kcgdend = kcgdend;
    }

    @Autowired
    public void setGnczService(GnczService gnczService) {
        this.gnczService = gnczService;
    }


    @Autowired
    public void setKcgdService(KcgdService kcgdService) {
        this.kcgdService = kcgdService;
    }

    @Autowired
    public void setXsdService(XsdService xsdService) {
        this.xsdService = xsdService;
    }

    @Autowired
    public void setKcgdDao(KcgdDao kcgdDao) {
        this.kcgdDao = kcgdDao;
    }

}
